package graphic.drawables;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

/**
 * Classe che rappresenta gli Sprite.
 *
 * @author Jan
 *
 */
public class Sprite {
	
	private int width;
	private int height;
	private int[] spritePixels;
	
	public Sprite(String path) {
		BufferedImage img = null;
		
		try {
			img = ImageIO.read( new File(path) );
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		if(img == null ){ return;}
		
		this.width = img.getWidth();
		this.height = img.getHeight();
		spritePixels = new int[ width*height];
		spritePixels = img.getRGB( 0, 0, width, height, null, 0, width);
//		for (int i = 0; i < height; i++) {
//			for (int j = 0; j < width; j++) {
//				spritePixels[j+i*width] = img.getRGB(j, i);
//			}
//		}
	}
	
	
	public int[] getSpritePixels() {
		return spritePixels;
	}
	
	public int getHeight() {
		return height;
	}
	
	public int getWidth() {
		return width;
	}
	
}
